import java.util.Scanner;

 

public class TriangleClassifier2 {

 

    // Method to classify the triangle based on its sides

    public static String classifyTriangle(int a, int b, int c) {

        // Check if the sides form a valid triangle using the triangle inequality theorem

        if (a + b > c && a + c > b && b + c > a) {

            if (a == b && b == c) {

                return "Equilateral";

            } else if (a == b || b == c || a == c) {

                return "Isosceles";

            } else {

                return "Scalene";

            }

        } else {

            return "Not a valid triangle";

        }

    }

 

    // Method to validate input and get a positive integer
    // 检查是否是正数
    public static int getValidSide(Scanner scanner, String sideName) {

        int side = 0;

        while (true) {

            try {

               System.out.print("Enter the " + sideName + " side: ");

                side = scanner.nextInt();

                // Check if the side is a positive number

                if (side > 0) {

                    break;

                } else {

                   System.out.println("Error: The side length must be a positive integer. Try again.");

                }

            } catch (Exception e) {

                // Handle non-integer inputs

               System.out.println("Error: Invalid input. Please enter a positive integer.");

                scanner.next(); // Clear the invalid input

            }

        }

        return side;

    }

 

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

 

        // Input 3-tuple for triangle sides with validation

        int side1 = getValidSide(scanner, "first");

        int side2 = getValidSide(scanner, "second");

        int side3 = getValidSide(scanner, "third");

 

        // Classify the triangle

        String result = classifyTriangle(side1, side2, side3);

       System.out.println("The triangle is: " + result);

       

        scanner.close();

    }

}